import { addProjectToDonor } from "./function.js"
import { getLocalDate } from "../../utils/getLocalDate.js"
Page({

  /**
   * 组件的属性列表
   */
  properties: {
    showIndex:null,
  },


  data: {
    showIndex:null,
    project:{},
    showDialog: false,
  },

  async donateItem(){
    this.setData({
      showIndex:null,
      showDialog: true,
    })
    //console.log(this.data.good);
    var amount =1;
    var date = await getLocalDate();
    //console.log(date);
    //JSON.stringify()
    var res=await addProjectToDonor("ourOx68K-yzP1JGUbwnM9FAEJ8hA",this.data.project , amount , (date));
  },


   /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    if (options.projectInfo) {
      var projectInfo =JSON.parse(decodeURIComponent(options.projectInfo));
      console.log(projectInfo)
      this.setData({
        project: projectInfo
      });
    }

  },

  


  openPopup(e){
    var index = e.currentTarget.dataset.index;
    this.setData({
      showIndex:index
    })
  },
  closePopup(){
    this.setData({
      showIndex:null
    })
  }
  
})